<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 注意,父子通信,不支持事件修饰符 -->
    <!-- <el-input @keyup.enter="handleEnter"></el-input> -->
    <!-- 通过dom事件的冒泡,注意这里子组件不用发消息 -->
    <!-- 完整写法 -->
    <!-- <div @keyup.enter="handleEnter">
      <el-input></el-input>
    </div> -->
    <!-- native,是dom事件的语法糖 -->
    <!-- 简化写法 -->
    <el-input @keyup.enter.native="handleEnter"></el-input>
  </div>
</body>
<script>
  Vue.component('el-input', {
    template: `
      <input/>
    `,
    methods: {
    }
  })
  new Vue({
    el: '#app',
    methods: {
      handleEnter() {
        console.log('键盘按下回车')
      }
    },
  })
</script>

</html>
